<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>添加</title>
<!-- Bootstrap -->
<link
	href="${pageContext.request.contextPath }/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" media="screen">
<link
	href="${pageContext.request.contextPath }/bootstrap/css/bootstrap-responsive.min.css"
	rel="stylesheet" media="screen">
<link href="${pageContext.request.contextPath }/assets/styles.css"
	rel="stylesheet" media="screen">

<link href="${pageContext.request.contextPath }/vendors/datepicker.css"
	rel="stylesheet" media="screen">
<link
	href="${pageContext.request.contextPath }/vendors/uniform.default.css"
	rel="stylesheet" media="screen">
<link href="${pageContext.request.contextPath }/vendors/chosen.min.css"
	rel="stylesheet" media="screen">

<link
	href="${pageContext.request.contextPath }/vendors/wysiwyg/bootstrap-wysihtml5.css"
	rel="stylesheet" media="screen">

<script
	src="${pageContext.request.contextPath }/vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>

<body>
	<div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container-fluid">
				<a class="btn btn-navbar" data-toggle="collapse"
					data-target=".nav-collapse"> <span class="icon-bar"></span>
				</a> <a class="brand" href="#">选课系统</a>
				<div class="nav-collapse collapse">
					<ul class="nav pull-right">
						<li class="dropdown"><a href="#" role="button"
							class="dropdown-toggle" data-toggle="dropdown"> <i
								class="icon-user"> </i>管理员: ${sessionScope.admin.name }<i
								class="caret"></i>

						</a>
							<ul class="dropdown-menu">
								<li><a tabindex="-1" href="user_logout.action?id=1">退出</a></li>
							</ul></li>
					</ul>
					<ul class="nav">
						<li class="active"><a href="#">查询</a></li>
						<li class="dropdown"><a href="#" data-toggle="dropdown"
							class="dropdown-toggle">查询 <b class="caret"></b>
						</a>
							<ul class="dropdown-menu" id="menu1">
								<li><a href="admin_teacherList.action">教师</a></li>
								<li class="divider"></li>
								<li><a href="admin_studentList.action">学生</a></li>
								<li class="divider"></li>
								<li><a href="admin_courseList.action">课程</a></li>
								<li class="divider"></li>
								<li><a href="admin_scList.action">选课</a></li>
							</ul></li>
						<li class="dropdown"><a href="#" role="button"
							class="dropdown-toggle" data-toggle="dropdown">编辑班级选课信息 <i
								class="caret"></i>
						</a>
							<ul class="dropdown-menu">
								<li><a tabindex="-1" href="admin_addCourseForClasses.action">添加</a></li>
								<li><a tabindex="-1" href="#">修改</a></li>
							</ul></li>
					</ul>
				</div>
				<!--/.nav-collapse -->
			</div>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span3" id="sidebar">
				<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
					<li class="active"><a><i class="icon-chevron-right"></i>
							查询</a></li>
					<li><a href="admin_teacherList.action"><i class="icon-chevron-right"></i>
							教师</a></li>
					<li><a href="admin_studentList.action"><i class="icon-chevron-right"></i>
							学生</a></li>
					<li><a href="admin_courseList.action"><i class="icon-chevron-right"></i>
							课程</a></li>
					<li><a href="admin_scList.action"><i class="icon-chevron-right"></i>
					                    选课</a>
					</li>
					<li class="active"><a><i class="icon-chevron-right"></i>
							编辑班级选课信息</a></li>
					<li><a href="admin_addCourseForClasses.action"><i class="icon-chevron-right"></i>
							添加</a></li>
					<li><a href="calendar.html"><i class="icon-chevron-right"></i>
							修改</a></li>
				</ul>
			</div>
			<!--/span-->
			<div class="span9" id="content">
				<!-- morris stacked chart -->
				<div class="row-fluid section">
					<!-- block -->
					<div class="block">
						<div class="navbar navbar-inner block-header">
							<div class="muted pull-left">给班级全部学生添加课程</div>
						</div>
						<div class="block-content collapse in">
							<div class="span12">
								<div id="rootwizard">
									<div class="navbar">
										<div class="navbar-inner">
											<div class="container">
												<ul>
													<li><a href="#tab1" data-toggle="tab">Step 1</a></li>
													<li><a href="#tab2" data-toggle="tab">Step 2</a></li>
													<li><a href="#tab3" data-toggle="tab">Step 3</a></li>
												</ul>
											</div>
										</div>
									</div>
									<div id="bar" class="progress progress-striped active">
										<div class="bar"></div>
									</div>
								
								<form id="form" action="admin_insertToClasses.action" class="form-horizontal">
									<div class="tab-content">
										<div class="tab-pane" id="tab1">
												<fieldset>
													<div class="control-group">
														<label class="control-label" for="focusedInput">选择学院</label>
														<div class="controls">
															<select class="input-xlarge focused" id="academy">
																<option selected value="">请选择</option>
															</select>
														</div>
													</div>
												</fieldset>
										</div>
										<div class="tab-pane" id="tab2">
												<fieldset>
													<div class="control-group">
														<label class="control-label" for="focusedInput">选择班级</label>
														<div class="controls">
															<select class="input-xlarge focused" id="classes"
																name="classesId"></option>
															</select>
														</div>
													</div>
												</fieldset>
										</div>
										<div class="tab-pane" id="tab3">
												<fieldset>
													<div class="control-group">
														<label class="control-label" for="focusedInput">选择要添加的课程</label>
														<div class="controls">
															<select class="input-xlarge focused" id="course"
																name="courseId"></option>
															</select>
														</div>
													</div>
												</fieldset>
										</div>
										<ul class="pager wizard">
											<li class="previous first" style="display: none;"><a
												href="javascript:void(0);">First</a></li>
											<li class="previous"><a href="javascript:void(0);">返回上一项</a></li>
											<li class="next last" style="display: none;"><a
												href="javascript:void(0);">下一项</a></li>
											<li class="next"><a href="javascript:void(0);">上一项</a></li>
											<li class="next finish" style="display:none;">
											  <a href="javascript:;">提交</a>
											 </li>
										</ul>
									</div>
								</form>
								</div>
							</div>
						</div>
					</div>
					<!-- /block -->
				</div>
			</div>
		</div>
		<hr>
	</div>
	<!--/.fluid-container-->


	<script
		src="${pageContext.request.contextPath }/vendors/jquery-1.9.1.js"></script>
	<script
		src="${pageContext.request.contextPath }/bootstrap/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/vendors/jquery.uniform.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/vendors/chosen.jquery.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/vendors/bootstrap-datepicker.js"></script>

	<script
		src="${pageContext.request.contextPath }/vendors/wysiwyg/wysihtml5-0.3.0.js"></script>
	<script
		src="${pageContext.request.contextPath }/vendors/wysiwyg/bootstrap-wysihtml5.js"></script>

	<script
		src="${pageContext.request.contextPath }/vendors/wizard/jquery.bootstrap.wizard.min.js"></script>

	<script type="text/javascript"
		src="${pageContext.request.contextPath }/vendors/jquery-validation/dist/jquery.validate.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/form-validation.js"></script>

	<script src="${pageContext.request.contextPath }/assets/scripts.js"></script>
	<script>
		$(function() {
			$(".datepicker").datepicker();
			$(".uniform_on").uniform();
			$(".chzn-select").chosen();
			$('.textarea').wysihtml5();

			$('#rootwizard').bootstrapWizard(
					{
						onTabShow : function(tab, navigation, index) {
							var $total = navigation.find('li').length;
							var $current = index + 1;
							var $percent = ($current / $total) * 100;
							$('#rootwizard').find('.bar').css({
								width : $percent + '%'
							});
							// If it's the last tab then hide the last button and show the finish instead
							if ($current >= $total) {
								$('#rootwizard').find('.pager .next').hide();
								$('#rootwizard').find('.pager .finish').show();
								$('#rootwizard').find('.pager .finish')
										.removeClass('disabled');
							} else {
								$('#rootwizard').find('.pager .next').show();
								$('#rootwizard').find('.pager .finish').hide();
							}
						}
					});
			$('#rootwizard .finish').click(function() {
				document.getElementById("form").submit();
				$('#rootwizard').find("a[href*='tab1']").trigger('click');
			});
		});
	</script>
	<script type="text/javascript">
		//获得学院
		$(document).ready(
				function() {
					$.ajax({
						url : "admin_getAllAcademy.action",
						dataType : "json",//设置需要返回的数据类型
						success : function(data) {
							var d = eval("(" + data + ")");
							if (!data)
								return;
							var html = "";
							for ( var i in d) {
								html += '<option value='+d[i].id+'>'
										+ d[i].name + '</option>';
							}
							$("#academy").append(html);
							$("#academy").change(function() {
								$("#classes").html("");
								$("#course").html("");
								getClasses(classes);
								getCourse(course);
							});
						}
					});
				});
		//获得班级
		function getClasses(classes) {
			$.ajax({
				url : "admin_getAllClasses.action",
				data : {
					aid : $("#academy").val()
				},
				dataType : "json",//设置需要返回的数据类型
				success : function(data) {
					var d = eval("(" + data + ")");
					if (!data)
						return;
					var html = '';
					for ( var i in d) {
						html += '<option value='+d[i].id+'>' + d[i].name
								+ '</option>';
					}
					$("#classes").append(html);
				}
			});
		}
		//获得课程
		function getCourse(course) {
			$.ajax({
				url : "admin_getAllCourse.action",
				data : {
					aid : $("#academy").val()
				},
				dataType : "json",//设置需要返回的数据类型
				success : function(data) {
					/* alert("可以获得数据!");
					alert(data); */
					var d = eval("(" + data + ")");
					if (!data)
						return;
					var html = '';
					for ( var i in d) {
						html += '<option value='+d[i].id+'>' + d[i].name
								+ '</option>';
					}
					$("#course").append(html);
				}
			});
		}
	</script>
	<script type="text/javascript">
		//获得学院
		$(document).ready(
				function() {
					//获取后台传递的值 
					var classes = '${classes}';
					var course = '${course}';
					$.ajax({
						url : "admin_getAllAcademy.action",
						dataType : "json",//设置需要返回的数据类型
						success : function(data) {
							var d = eval("(" + data + ")");
							if (!data)
								return;
							var html = "";
							for ( var i in d) {
								html += '<option value='+d[i].id+'>'
										+ d[i].name + '</option>';
							}

							$("#academy option").each(function() {
								if ($(this).text() == citys[0]) {
									$(this).attr("selected", true);
									getClasses(classeses);
									getCourse(course);
								}
							})

							$("#academy").change(function() {
								$("#classes").html("");
								$("#course").html("");
								getClasses(null);
								getCourse(null);
							});
						}
					});
				});
		//获得班级
		function getClasses(classes) {
			$.ajax({
				url : "admin_getAllClasses.action",
				data : {
					aid : $("#academy").val()
				},
				dataType : "json",//设置需要返回的数据类型
				success : function(data) {
					var d = eval("(" + data + ")");
					if (!data)
						return;
					var html = '';
					for ( var i in d) {
						html += '<option value='+d[i].id+'>' + d[i].name
								+ '</option>';
					}
					$("#classes").append(html);

					if (classes != null) {
						$("#classes option").each(function() {
							if ($(this).text() == classes) {
								$(this).attr("selected", true);
							}
						})
					}
				}
			});
		}
		//获得课程
		function getCourse(course) {
			$.ajax({
				url : "admin_getAllCourse.action",
				data : {
					aid : $("#academy").val()
				},
				dataType : "json",//设置需要返回的数据类型
				success : function(data) {
					/* alert("可以获得数据!");
					alert(data); */
					var d = eval("(" + data + ")");
					if (!data)
						return;
					var html = '';
					for ( var i in d) {
						html += '<option value='+d[i].id+'>' + d[i].name
								+ '</option>';
					}
					$("#course").append(html);
					if (course != null) {
						$("#course option").each(function() {
							if ($(this).text() == course) {
								$(this).attr("selected", true);
							}
						})
					}

				}
			});
		}
	</script>
</body>
</html>